﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Entities;
using Comm;
using BusinessFacade;

namespace MedicareNoteManagerWeb.Web
{
    public partial class Roles_add : System.Web.UI.Page
    {
        sys_user_Model model1 = new sys_user_Model();
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        string CheckData()
        {
            string strErr = "";
            if (string.IsNullOrEmpty(txtRoleName0.Text.Trim()))
            {
                strErr += "角色名不能为空";
            }
            if (string.IsNullOrEmpty(txtRoleName1.Text.Trim()))
            {
                strErr += "描述不能为空";
            }
            return strErr;
        }
        public void GetMode(sys_role_Model model)
        {
          
                model.RoleName = txtRoleName0.Text.Trim();
                model.Remark = txtRoleName1.Text.Trim();
                model.CreateUserID = model1.UserID;
                model.CreateDate = DateTime.Now;
                model.RoleID = 0;

        }
        protected void BtnOk_Click(object sender, EventArgs e)
        {
            model1 = (sys_user_Model)Session["UserModel"];
            sys_role_Model model = new sys_role_Model();
            GetMode(model);
            string strErr = CheckData();
            if (string.IsNullOrEmpty(strErr))
            {
                if (new Busi_sys_Role().Add(model))
                {
                    MessageBox.ShowDialog(Page, "添加成功！", "success");
                }
                else
                {
                    MessageBox.ShowDialog(Page, "添加失败！", "error");
                }


            }
            else
            {
                MessageBox.ShowDialog(Page, "添加失败！" + strErr, "error");
            }
        }
    }
}